const cloudbase = require('@cloudbase/node-sdk')

// 初始化云开发
const app = cloudbase.init({
    env: cloudbase.SYMBOL_CURRENT_ENV
})
const db = app.database()

exports.main = async (event, context) => {
    try {
        // 查询推荐模板数据，按sort字段升序排列
        const res = await db.collection('recommend_template')
            .get()

        return {
            code: 0,
            message: 'success',
            data: res.data
        }
    } catch (err) {
        console.error(err)
        return {
            code: -1,
            message: err.message,
            data: null
        }
    }
}